package com.eportal.util;


/** 
 * CRC16相关计算  
 
 * encode: utf-8 
 */  
public class CrcUtil {  
   
	
	public static int crc16(String str){
		char[] arr = str.toCharArray();
		char l,h,t;
		int val;
		l=h=0xff;
		for(int i=0;i<arr.length;i++){
			h ^= arr[i];
			h ^= h>>4;
			t=h;
			h=l;
			l=t;
			t=(char) ((l<<4) | (l>>4));
			h ^=((t<<2) | (t>>6)) & 0x1f;
			h ^=t & 0xf0;
			l ^= ((t<<1) | (t>>7)) & 0xe0;
			
		}
		val = ((int)h<<8) | l;
		return val;
	}

}  